(function (w ) {
   
   /** Please Compare also the data from phonegallery.php  "$pricerange" */
    var _priceRanges=[
        "price_a",
        "price_b",
        "price_c",
        "price_d",
        "price_e",
    ];
        
    // @clasname @boolean(true:show overwise hide)
//    w.fn.classItemLabasTago = function(clas, x){
//        if (x=== true)w(clas).show();
//        else w(clas).show();
//    };
    
    w.fn.wFilters = function(options) {
        var s = w.extend({
            // These are the defaults.
            _currentPrice:"",
            _currentBrand: "",
            _lastFilter:"", // [price,brand]
        }, options );
        //console.log("wFilters Start");
    /*
        // Todo, create the currect filter
        w('#price .price').click(function(){

            //w("#products-list .price_c").show();// Since all brand I guess Price made the hiding
//            s._lastFilter="price";
            
//            if (w(this).attr('key') === s._currentPrice){
//                console.log("Paulit-ulit??? halerr");
//                return false;
//            }
            
            // @TODO/TOFOLLOW combine the of filters of price and phones
            console.log("Click price #"+w(this).attr('key')+"#");
            if(w(this).attr('key') === 'all'){
                // Show all
//                if(s._currentBrand === "All" || (s._currentBrand === "")){
//                    console.log("ALL Show current price #{"+s._currentPrice+"}");
//                    w("."+s._currentPrice).show();// Since all brand I guess Price made the hiding
//                    console.log('SHOW Price {'+s._currentPrice+"}");
//                }else{
//                    console.log('SHOW brand {'+s._currentBrand+"}");
//                    w(".brand_"+s._currentBrand).show();
//                }
//                
//                s._currentPrice="";
                
            }else if(s._currentPrice !== ""){
//                w("."+s._currentPrice).hide();
//                console.log('Hide  price {'+s._currentPrice+"}");
                s._currentPrice = w(this).attr('key');
//                w("."+s._currentPrice).show();
//                console.log('SHOW  price {'+s._currentPrice+"}");
            }else{
                s._currentPrice = w(this).attr('key');
//                w("#products-list .price_c").removeClass("_display").addClass("_hide");
//                console.log("Price no Click #"+s._currentPrice);
//                 //Hide what is no on the list
//                for(var x in _priceRanges){
//                    var  __classPrice  = _priceRanges[x];
//                    console.log("each price "+x + " -> "+__classPrice);
//                    if (__classPrice !== s._currentPrice){
//                        w("#products-list ."+__classPrice).hide();
//                        console.log("HIDE Price "+x + " -> "+__classPrice);
//                    }else{
//                        w("#products-list ."+__classPrice).show();
//                        console.log("SHOW Price "+x + " -> "+__classPrice);
//                    }
//                }
            }

        });
        */
        
        // Everytime this got change, price will directly reset.
        /*w(".width72P").on("change", function(e) {
            // @TODO/TOFOLLOW combine the of filters of price and phones
            // Phone Brand Dropdown
            //console.log("Phone "+e.value);
            console.log("change "+e.val);
            s._currentBrand=e.val;
            s._lastFilter="brand";
            s._currentPrice=""; // reset
            if (s._currentBrand === "All"){
                
            }
//            if(s._currentBrand !== ''){
//                w(s._currentBrand).show();
//            }else if("brand_"+s._currentBrand === 'All'){
//                console.log('App Phone brand');
//                w("brand_"+s._currentBrand).show();
//                s._currentBrand='';
//            }else{
//                s._currentBrand = w(this).attr('key');
//                w("brand_"+s._currentBrand).hide();
//            }
//            console.log("Current Brand -> "+s._currentBrand);
        });*/
        
    /*
        w(".gallery-filter a[href='#filter']").click(function(){
            console.log("Click .gallery-filter a[href='#filter']");
            //console.log("Click #gallery-filter-by-collapse");
            w(this).children("span").toggleClass("expand");
            w(".gallery-filter .filters").slideToggle("slow", function(){
                
            });
            return  false;
        });
        w(".gallery-filter .filters a[href='#price']").click(function(){
            console.log("Click .gallery-filter .filters a[href='#price']");
            w(this).children("span").toggleClass("expand");
            // I want jquery handle the toggle
            w("#price").slideToggle("slow",function(){
                
            });
            return false;
        });
//        w(".filters a").click(function(){
//            console.log("Price collapse click {anchor}");
//            if(/w(this).attr("class")/.test("expand")){
//                // open the price
////                w("#price").show();
//            }else{
//                // close price
////                w("#price").hide();
//            }
//            // I want jquery handle the toggle
//            w("#price").slideToggle("slow",function(){
//                // You extra process here.. :)
//            }); 
//        });
        
    };
    w(document).ready(function(){
        w(document).wFilters();
        console.log("wDocument Ready");
    });
}( jQuery ));